function [val,grad] = QP_obj(x)
% Objective fn for QP problem.

% Global variables:

global Q N_alphas muZpH_vec N_types

% Alphas weighted by pref. class probabilities:

am = x(1:N_alphas) .* muZpH_vec ;

% Objective function value and gradient:

val = 0.5 * am' * Q * am;
grad = vertcat( Q * am, zeros(2*N_types,1) );

end
